﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.ActiveRecord;
using ZDSoft.TES.Entity.SystemEntity;
using ZDSoft.QLMS.Entity.TestOnline;

namespace ZDSoft.QLMS.Entity.SystemSetting
{
    [ActiveRecord]
    public class Organization : EntityBase<Organization>
    {
        /// <summary>
        /// 机构名称
        /// </summary>
        [Property]
        public string OrganizationName { get; set; }

        /// <summary>
        /// 机构类型
        /// </summary>
        [Property]
        public OrganizationType OrganizationType { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        [Property]
        public bool IsActive { get; set; }

        [BelongsTo("ParentID", Lazy = FetchWhen.OnInvoke)]
        public Organization Parent { get; set; }

        [HasMany(typeof(Organization), ColumnKey = "ParentID", Inverse = true)]
        public IList<Organization> Children { get; set; }

        [HasMany(typeof(User), ColumnKey = "OrganizationID", Inverse = true)]
        public IList<User> Users { get; set; }

        [HasAndBelongsToMany(typeof(Test), Table = "Organization_Test", ColumnRef = "OrganizationID", ColumnKey = "TestID")]
        public IList<Test> Organizations { get; set; }
    }
}
